﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Caching;
namespace ECommerce.DAO.Cache.Personas
{
    public static class Proveedor
    {
        public static ECommerce.Model.Personas.Proveedor GetProveedorById(Int32 Id)
        {
            ECommerce.Model.Personas.Proveedor Proveedor = new ECommerce.Model.Personas.Proveedor();
            try
            {
                Proveedor = (ECommerce.Model.Personas.Proveedor)HttpRuntime.Cache["Proveedor-" + Id.ToString()];
            }
            catch (Exception ex)
            {
                Proveedor = null;
            }
            if (Proveedor.Id == 0)
                Proveedor = null;
            return Proveedor;
        }
        public static int SetProveedor(ECommerce.Model.Personas.Proveedor Proveedor)
        {
            try
            {
                HttpRuntime.Cache.Insert("Proveedor-" + Proveedor.Id.ToString(), Proveedor);
            }
            catch (Exception ex)
            {
            }
            return Proveedor.Id;
        }
        public static int DelProveedor(ECommerce.Model.Personas.Proveedor Proveedor)
        {
            try
            {
                HttpRuntime.Cache.Remove("Proveedor-" + Proveedor.Id.ToString());
            }
            catch (Exception ex)
            {
            }
            return Proveedor.Id;
        }

     }
}
